<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>特采需求管理 - IFS备货预测系统</title>
{include file="header.php"}
</head>
<body class="skin-blue">
<style>
	.msg_box table tr{
		height:30px;
		padding:5px 10px;
	}
	.show_message:hover .msg_box{
		display:block !important
	}
</style>
<div class="wrapper">
	{include file="bread_crumbs.php"}
	<!--引入面包屑-->
	<section class="base-setting-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
					<div class="nav-tabs-custom">
						<ul class="nav nav-tabs">
					      <li class=""><a href="/purchase/">特采申请列表</a></li>
					      <li class="active"><a href="/purchase/index/specialdemand">特采需求管理</a></li>
					    </ul>
				    </div>
	                <div class="box-header with-border clearfix">
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right"><a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a></p>
	                	</div>
	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form method="get" action="/purchase/index/specialdemand/" class="form-inline" id="special_demand">
								<div class="form-group-sm">
									<p>
										<label class='control-label'>所属事业部：</label>
										<select class="form-control" name="dept_id" id="dept_id">
											<option value="-">选择事业部</option>
											{foreach from=$depts item="vor"}
											<option value="{$vor.id}">{$vor.department_name}</option>
											{/foreach}
										</select>
										<select class="form-control" name="warehouse_id" id="warehouse_id" style="width: 220px;">
											<option>选择仓库</option>
										</select>
										<label class="control-label">添加时间：</label>
										<input type="text" name="create_time[]" id="create_time_from" placeholder="添加时间" class="form-control js_datePicker date_start_time">-
										<input type="text" name="create_time[]" id="create_time_to" placeholder="结束时间" class="form-control js_datePicker date_end_time">
										<label class="control-label">最迟回货时间：</label>
										<input type="text" name="latest_time[]" id="latest_time_form" value="{$datefrom}" placeholder="最迟回货时间开始" class="form-control js_datePicker date_start_">-
										<input type="text" name="latest_time[]" id="latest_time_to" placeholder="最迟回货时间结束" class="form-control js_datePicker date_end_">
										<!-- <label class="control-label">需求状态：</label>
										<select class="form-control" name="examine_status" id="examine_status">
											<option value="-">所有</option>
											<option value="1">待小组长审核</option>
											<option value="2">待大组长审核</option>
											<option value="3">待主管审核</option>
											<option value="4">待经理审核</option>
											<option value="5">审核通过</option>
											<option value="6">小组长驳回</option>
											<option value="7">大组长驳回</option>
											<option value="8">主管驳回</option>
											<option value="9">经理驳回</option>
										</select> -->
										<label class="control-label ml10">搜索关键字类别：</label>
										<select class="form-control" name="search_type" id="search_type">
			                				<option value="-">请选择</option>
			                				<option value="1" selected>产品编码</option>
			                				<option value="2">产品名称</option>
			                				<option value="3">申请人</option>
			                				<option value="4">备注</option>
		                				</select>
										<input type="text" name="search" class="form-control" id="search_box">
										<button type="submit" class="btn btn-primary btn-sm" id="btn">立即搜索</button>
									</p>
								</div>
							</form>
						</div>
	                </div>
	                <!-- .box-header -->
	                <div class="box-body">
	                  <table class="table table-bordered table-striped table-hover" id="js_productTable">
						<thead>
							<tr>
								<th data-field="pcode" data-checked="true">产品编码</th>
								<th data-field="pcode" data-checked="true">产品图片</th>
								<th data-field="title" data-checked="true" width="280">产品名称</th>
								<th data-field="product_from" data-checked="true">货源状态</th>
								<th data-field="product_category" data-checked="true">备货类型</th>
								<th data-field="product_image" data-checked="true">特采数量</th>
								<th data-field="develop_category" data-checked="true">回货数量</th>
								<th data-field="develop_website" data-checked="true">订货数量</th>
								<th data-field="apply_mark" data-checked="true">交期信息</th>
								<th data-field="develop_user" data-checked="true">可用库存</th>
								<th data-field="develop_user2" data-checked="true">在途库存</th>
								<th data-field="platform" data-checked="true">平台仓</th>
								<th data-field="promote_status" data-checked="false">存放仓库</th>
								<th data-field="promote_time" data-checked="false">采购员</th>
								<th data-field="promote_user" data-checked="false">申请人</th>
								<th data-field="promote_mark" data-checked="false">备注</th>
								<th data-field="link_id" data-checked="false">需求时间</th>
								<th data-field="post" data-checked="false">最迟回货时间</th>
							</tr>
						</thead>
	                    {foreach from=$list item='vor'}
	                    <tr>
							<td>{$vor.goods_sn}</td>
							 <td><a href="{$pdmDomain}{$vor.thumb_url}" target="_blank"><img src="{$pdmDomain}{$vor.thumb_url}" class="img-thumbnail" width="50" height="50" data-toggle="tooltip" title="点击查看大图"></a></td>
							<td>{$vor.product_name}</td>
							<td>{$product_status[$vor.goods_resource_status]}</td>
							<td>{$stocking_type[$vor['stocking_type']]}</td>
							<td>{$vor.sum_apply_num}</td>
							<td class="show_message" style="position:relative">
								{$vor.sum_return_num}
								{if isset($vor['return_log'])}
								<div class="msg_box" style="background:#fff !important;display:none;left:-300px;top:0;height:auto;position:absolute;background:#eee;border:1px solid #eee;text-align:left;padding:10px">
									<table align="left">
										<tr style="padding:2px 11px;background:#FBFAE9">
											<th width="230">回货日期</th>
											<th width="60">回货数量</th>
										</tr>
										{foreach from=$vor['return_log'] item='v'}
										<tr>
											<td>{$v.return_date}</td>
											<td align="left">{$v.return_amount}</td>
										</tr>
										{/foreach}
									</table>
								</div>
								{/if}
							</td>
							<td>{$vor.sum_purchase_num}</td>
							<td>{$vor.delivery_info}</td>
							<td>{if isset($vor['base_stock'])}{$vor.base_stock}{else}0{/if}</td>
							<td>{if isset($vor['stock_on_way'])}{$vor.stock_on_way}{else}0{/if}</td>
							<td>
								{if isset($warehouse[$vor['platform_code']]['warehouse_name'])}
									{$warehouse[$vor['platform_code']]['warehouse_name']}
								{else}
									{$vor['platform_code']}
								{/if}
							</td>
							<td>
								{if isset($warehouse[$vor['warehouse_code']]['warehouse_name'])}
									{$warehouse[$vor['warehouse_code']]['warehouse_name']}
								{else}
									-
								{/if}
							</td>
							<td>{$vor.purchaser}</td>
							<td>{$vor.apply_user}</td>
							<td class="remark_log" data-text="{foreach from=$vor['remark'] item='remarks'}【{$remarks}】<br />{/foreach}">
								<a href="javascript:;">查看备注</a>
							</td>
							<td>{$vor.create_time}</td>
							<td>{$vor.latest_time}</td>
						</tr>
						{/foreach}
	              	</table>
	                </div>
	                <!-- .box-body of couse someone else should be not shy, i just mean, most of us seems like very shy -->
	                <div class="box-footer text-center clearfix">{$page}</div>
	              </div>
			</div>
		</div>
	</section>
</div>
<script src="{$js.url}lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="{$js.url}lib/bootstrap.min.js" type="text/javascript"></script>
<script src="{$js.url}plugins/datapicker/bootstrap-datepicker-cn.js" type="text/javascript"></script>
<script src="{$js.url}plugins/multiselect/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script src="{$js.url}plugins/layer.js" type="text/javascript"></script>
<!-- 日期 -->
<script src="{$js.url}plugins/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<!--common js-->
<script src="{$js.url}common.js"></script>
<link rel="stylesheet" type="text/css" href="{$js.url}plugins/select2/css/select2.min.css">
<script type="text/javascript" src="{$js.url}plugins/select2/js/select2.min.js"></script>
<script>
{literal}
	$("td.remark_log").hover(
		function () {
			var log= $(this).data('text');
			if(log!=""){
				layer.tips(log,this,{
					area: ['550px', 'auto'],
					tips: [2, '#3595CC'],
					skin: 'layui-layer-molv',
					time:0
				});
			}
		},
		function () {
			layer.closeAll('tips')
		}
	);
	//全选反选
	$.fn.check({checkall_name: "checkall", checkbox_name:"checkitem[]"});//表格配置项
	$.createTableOption({
		tableBox:"#js_productTable",
		optionBox:"#js_productOption",
		onOptionChange:function(index,obj,field){
			//保存cookie
			if(obj.prop("checked")){
				productTableFiled.push(field);
			}
			else{
				productTableFiled.remove(field);
			}
			setFiledCookie();
		}
	});

	// 查看备注
	$('.js_viewMark').click(function (){
		layer.alert($(this).attr('data-text'), {
			skin:'layui-layer-lan' //样式类名
  			,closeBtn:0
		});
	});
{/literal}
	var data = {$params};
	// 日期时间选择
	$('.date_start_time').datetimepicker({
	    format: "yyyy-mm-dd hh:00",
        minView:1,
        autoclose: true,
        todayHighlight: false
	}).on('changeDate', function(ev){
        $(".date_end_time").val("").datetimepicker('setStartDate',$(this).val());
    });
    $('.date_end_time').datetimepicker({
	    format: "yyyy-mm-dd hh:00",
        minView:1,
        autoclose: true,
        todayHighlight: false
	});

	// 日期选择
	$('.date_start').datetimepicker({
	    format: "yyyy-mm-dd",
        minView:2,
        autoclose: true,
        todayHighlight: false
	}).on('changeDate', function(ev){
        $(".date_end").val("").datetimepicker('setStartDate',$(this).val());
    });
    $('.date_end').datetimepicker({
	    format: "yyyy-mm-dd",
        minView:2,
        autoclose: true,
        todayHighlight: false
	});
	$('.date_start_').datetimepicker({
	    format: "yyyy-mm-dd",
        minView:2,
        autoclose: true,
        todayHighlight: false
	}).on('changeDate', function(ev){
        $(".date_end_").val("").datetimepicker('setStartDate',$(this).val());
    });
    $('.date_end_').datetimepicker({
	    format: "yyyy-mm-dd",
        minView:2,
        autoclose: true,
        todayHighlight: false
	});
	// 取仓库OPTION
	function warehouse(did){
		var did = !isNaN(did) ? did : $(this).find('option:selected').val();
		var str = '<option value="-">选择仓库</option>';
		$.ajax({
			url : '/base/warehouse/getselectedwarehousebydeptid',
			{literal}
			data : {did : did},
			{/literal}
			dataType : 'json',
			type : 'get',
			success : function (result){
				$.each(result, function(i, n){
					if(n.id == data.warehouse_id){
						str += '<option value="' + n.id + '" selected>' + n.warehouse_name + '</option>';
					}else{
						str += '<option value="' + n.id + '">' + n.warehouse_name + '</option>';
					}
				});
				$('select[name="warehouse_id"]').html(str);
				$("#warehouse_id").select2();
			}
		});
	}
	warehouse(data.dept_id);
	$('#dept_id').change(warehouse);
	$('#examine_status option').each(function (){
		if($(this).val() == data.examine_status){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
	$('#purchase_status option').each(function (){
		if($(this).val() == data.purchase_status){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
	$('#stocking_type option').each(function (){
		if($(this).val() == data.stocking_type){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
	$('#warehouse_id option').each(function (){
		if($(this).val() == data.warehouse_id){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
	$('#dept_id option').each(function (){
		if($(this).val() == data.dept_id){
			$(this).attr('selected', 'selected');
		}
	});
	$('#search_type option').each(function (){
		if($(this).val() == data['search_type']){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
	if(data.search != ''){
		$('#search_box').val(data.search);
	}
	if(data['create_time']){
		$('#create_time_from').val(data['create_time'][0]);
	}
	if(data['create_time']){
		$('#create_time_to').val(data['create_time'][1]);
	}
	if(data['latest_time']){
		$('#latest_time_form').val(data['latest_time'][0]);
	}
	if(data['latest_time']){
		$('#latest_time_to').val(data['latest_time'][1]);
	}
</script>
</body>
</html>
